<?php

namespace app\common;


abstract class BaseService
{

  private static $instances = [];

  public static function getInstance() {
    if (!isset(self::$instances[static::class])) {
      self::$instances[static::class] = new static();
    }
    return self::$instances[static::class];
  }

  /**
   * 全角转半角
   * @param string $str
   * @return string
   **/
  protected function sbc2Dbc($str) {
    $dbc = array('０','１','２','３','４','５','６','７','８','９','Ａ','Ｂ','Ｃ','Ｄ','Ｅ','Ｆ','Ｇ','Ｈ','Ｉ','Ｊ','Ｋ','Ｌ','Ｍ','Ｎ','Ｏ','Ｐ','Ｑ','Ｒ','Ｓ','Ｔ','Ｕ','Ｖ','Ｗ','Ｘ','Ｙ','Ｚ','ａ','ｂ','ｃ','ｄ','ｅ','ｆ','ｇ','ｈ','ｉ','ｊ','ｋ','ｌ','ｍ','ｎ','ｏ','ｐ','ｑ','ｒ','ｓ','ｔ','ｕ','ｖ','ｗ','ｘ','ｙ','ｚ','－','　','：','．',',','／','％','＃','!','＠','＆','(',')','＜','＞','＂','＇','?','［','］','｛','｝','＼','｜','＋','＝','＿','＾','￥','￣','｀');
    $sbc = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','-',' ',':','.','/','%','#','@','&','<','>','"','\'','[',']','{','}','\\','|','+','=','_','^','~','`');
    return str_replace($dbc,$sbc, $str); //全角到半角
  }
}